<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>青岛市市立医院 - 来院交通</title>
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
		<link rel="stylesheet" href="./css/index.css">
		<style>
			/* 搜索结果的样式 */
			.search-result-item {
				padding: 15px;
				border-bottom: 1px solid #eee;
				margin-bottom: 10px;
				transition: all 0.3s;
			}

			.search-result-item:hover {
				background-color: #f9f9f9;
			}

			.search-result-title {
				font-weight: bold;
				color: #2c8a3e;
				margin-bottom: 8px;
				font-size: 18px;
			}

			.search-result-content {
				color: #555;
				line-height: 1.6;
			}

			.no-results {
				padding: 30px;
				text-align: center;
				color: #777;
				font-size: 16px;
			}

			.search-highlight {
				background-color: #fffde7;
				padding: 0 2px;
				border-radius: 2px;
			}

			.search-header {
				margin-bottom: 20px;
				font-size: 18px;
				color: #333;
			}

			.search-keyword {
				color: #2c8a3e;
				font-weight: bold;
			}
		</style>
	</head>
	<body>
		<!-- 头部区域 -->
		<header class="hospital-header">
			<div class="hospital-container">
				<div class="hospital-topbar">
					<div class="hospital-logo" style="margin:18px 105px 0px 8px">
						<img src="./static/imgs/logo.jpg" width="260px" alt="医院标志">
					</div>
					<div class="header-rg">
						<span style="font-size: 14px;">
							<a href="appointments.html" target="_blank"
								style="text-decoration: none; color: dimgray;">预约挂号</a>
							|
							<a href="zhuanjiaList.html" target="_blank"
								style="text-decoration: none; color: dimgray;">专家介绍</a>
							|
							<a href="lyjt.html" target="_blank" style="text-decoration: none; color: dimgray;">来院交通</a>
							|
							<a href="contact.html" target="_blank"
								style="text-decoration: none; color: dimgray;">联系我们</a>
						</span>
						<div class="hospital-search">
							<input type="text" id="searchInput" placeholder="输入关键词搜索..." style="width: 210px;">
							<button id="searchButton" style="background: none; border: none; cursor: pointer;">
								<img src="static/imgs/ss.gif" alt="搜索">
							</button>
						</div>
					</div>
				</div>
				<nav class="hospital-nav">
					<ul class="nav-menu">
						<li><a href="index.html">首页</a></li>
						<li><a href="zhuanjiaList.html">专家介绍</a></li>
						<li><a href="chat.html">智能预约</a></li>
						<li><a href="medical-info.html">医疗知识库</a></li>
						<li><a href="appointments.html">我的预约</a></li>
						<li><a href="profile.html">个人中心</a></li>
						<li><a href="lyjt.html">来院交通</a></li>
						<li><a href="contact.html">联系我们</a></li>
					</ul>
				</nav>
			</div>
		</header>

		<!-- 主要内容区 -->
		<main class="hospital-main" style="padding-top: 8px;">
			<div class="hospital-container">
				<div class="content-row">
					<div class="main-content">
						<div class="content-card" style="padding: 20px;">
							<div class="search-header">
								搜索关键词: <span class="search-keyword" id="searchKeyword"></span>
							</div>
						</div>
						<div class="content-card">
							<div class="card-title">
								<span>搜索结果</span>
							</div>
							<div class="card-body" id="searchResults">
								<!-- 结果将通过JS动态加载 -->
							</div>
						</div>
					</div>
				</div>
			</div>
		</main>

		<!-- 页脚区域 -->
		<footer class="hospital-footer">
			<div>
				<p>Copyright©青岛市市立医院（集团）</p>
				<p>鲁ICP备09051934号</p>
				<p>医院邮箱：qdsslyybgs@qd.shandong.cn</p>
				<p>技术支持：22计算机3姚志诚</p>
			</div>
		</footer>
		<script src="./js/common.js"></script>
		<script>
			// 搜索数据（与之前相同）
			const searchData = [{
					title: "高血压的预防与管理",
					content: "高血压是一种常见的慢性病，长期未控制会增加心脑血管疾病风险。预防措施包括低盐饮食、规律运动、控制体重和限制饮酒。",
					url: "medical-info.html#hypertension",
					category: "医疗知识"
				},
				{
					title: "糖尿病饮食指南",
					content: "糖尿病患者应遵循均衡饮食原则，控制总热量摄入，选择低GI食物，合理分配碳水化合物、蛋白质和脂肪比例。",
					url: "medical-info.html#diabetes",
					category: "医疗知识"
				},
				{
					title: "心血管内科专家团队",
					content: "我院心血管内科拥有多位资深专家，擅长高血压、冠心病、心律失常等疾病的诊断和治疗。",
					url: "zhuanjiaList.html#cardiology",
					category: "专家介绍"
				},
				{
					title: "来院交通指南",
					content: "青岛市市立医院位于市南区，可乘坐地铁3号线在市立医院站下车，或乘坐公交25路、26路、31路等在市立医院站下车。",
					url: "lyjt.html",
					category: "医院服务"
				},
				{
					title: "预约挂号流程",
					content: "您可以通过官网、微信公众号或医院APP进行预约挂号，预约成功后请按时就诊，迟到30分钟将取消预约。",
					url: "appointments.html",
					category: "医院服务"
				},
				{
					title: "儿科门诊时间调整",
					content: "自2023年10月起，儿科门诊时间调整为周一至周日8:00-17:00，急诊24小时开放。",
					url: "index.html#news",
					category: "医院公告"
				},
				{
					title: "体检中心服务项目",
					content: "体检中心提供多种体检套餐，包括入职体检、健康体检、公务员体检等，可提前预约。",
					url: "medical-info.html#checkup",
					category: "医院服务"
				}
			];

			// 获取URL中的搜索关键词
			function getQueryParam(name) {
				const urlParams = new URLSearchParams(window.location.search);
				return urlParams.get(name);
			}

			// 高亮显示关键词
			function highlightKeyword(text, keyword) {
				if (!keyword) return text;
				const regex = new RegExp(keyword, 'gi');
				return text.replace(regex, match => `<span class="search-highlight">${match}</span>`);
			}

			// 显示搜索结果
			function displaySearchResults() {
				const keyword = getQueryParam('q');
				const searchKeywordEl = document.getElementById('searchKeyword');
				const searchResults = document.getElementById('searchResults');

				if (keyword) {
					searchKeywordEl.textContent = keyword;

					const lowerKeyword = keyword.toLowerCase();
					const results = searchData.filter(item =>
						item.title.toLowerCase().includes(lowerKeyword) ||
						item.content.toLowerCase().includes(lowerKeyword)
					);

					if (results.length > 0) {
						let html = '';
						results.forEach(item => {
							const highlightedTitle = highlightKeyword(item.title, keyword);
							const highlightedContent = highlightKeyword(item.content, keyword);

							html += `
			                            <div class="search-result-item">
			                                <div class="search-result-title">
			                                    <a href="${item.url}" style="text-decoration: none; color: inherit;">${highlightedTitle}</a>
			                                    <span style="float: right; font-size: 12px; color: #888;">${item.category}</span>
			                                </div>
			                                <div class="search-result-content">${highlightedContent}</div>
			                            </div>
			                        `;
						});
						searchResults.innerHTML = html;
					} else {
						searchResults.innerHTML = `<div class="no-results">没有找到与"${keyword}"相关的结果</div>`;
					}
				} else {
					searchResults.innerHTML = '<div class="no-results">请输入关键词搜索医院相关信息</div>';
				}
			}

			// 页面加载时显示结果
			document.addEventListener('DOMContentLoaded', displaySearchResults);
		</script>
	</body>
</html>